var imgLoaded = true;

var price_small = 0; //最小价格

var price_big = 0; //最大价格

var is_trade = 0; //是否在交易期

$(function () {

    var startNum = 0;   // 每次请求时，图片从第几张开始加载。
    var limitNum = 10;   // 每次请求时，图片加载的数量。

    var Ourl = httpHost + "/Bargain/bargainList?start=" + startNum + "&limit=" + limitNum + "&type=" + $(".entrust_category ul li").eq(0).attr("type") + "&stage=" + $(".entrust_category ul li").eq(1).attr("type") + "&issue_no=" + $(".entrust_category ul li").eq(2).attr("type") + "&select_time=" + $(".entrust_category ul li").eq(3).attr("type") + "&user_opp=" + $(".entrust_category ul li").eq(4).attr("type");
    loadArts(Ourl, startNum);

    $(window).scroll(function () {
        if (($(window).height() + document.body.scrollTop)+10 >= document.body.scrollHeight) {
            if (imgLoaded) {
                startNum += limitNum;
                Ourl = httpHost + "/Bargain/bargainList?start=" + startNum + "&limit=" + limitNum + "&type=" + $(".entrust_category ul li").eq(0).attr("type") + "&stage=" + $(".entrust_category ul li").eq(1).attr("type") + "&issue_no=" + $(".entrust_category ul li").eq(2).attr("type") + "&select_time=" + $(".entrust_category ul li").eq(3).attr("type") + "&user_opp=" + $(".entrust_category ul li").eq(4).attr("type");
                imgLoaded = false;
                loadArts(Ourl, startNum);
            }
        }
    });

    $(".loading_style").show();

    $(".entrust_category ul li").tap(function(){
        //isLogin();
        var category = $(this).attr("category");
        $('.opa_background').show();
        $(".entrust_category_news").show();
        var categoryText = 0;
        $(".entrust_category_news ul").each(function(){
            categoryText = $(this).attr("categoryText");
            if(category == categoryText){
                $(".entrust_category_news ul").hide();
                $(this).show();
            }
        });
        $(".entrust_category_news ul li").off("tap").on("tap",function(){
            var categoryText = $(this).parent().attr("categoryText");
            var thistext = $(this).text();
            var type = $(this).attr("type");
            $(this).parent().find("li").css("background","none");
            $(this).css("background","url('/public/m/image/global/rightYes.png') 680px 35px no-repeat");
            $('.opa_background').hide();
            $(".entrust_category_news").hide();
            var category = 0;
            $(".entrust_category ul li").each(function(){
                category = $(this).attr("category");
                if(categoryText == category){
                    $(this).text(thistext).attr("type",type).css("list-style","none");
                }
            });

            $(".bar_index_news").remove();
            startNum = 0;
            var Ourl = httpHost + "/Bargain/bargainList?start=" + startNum + "&limit=" + limitNum + "&type=" + $(".entrust_category ul li").eq(0).attr("type") + "&stage=" + $(".entrust_category ul li").eq(1).attr("type") + "&issue_no=" + $(".entrust_category ul li").eq(2).attr("type") + "&select_time=" + $(".entrust_category ul li").eq(3).attr("type") + "&user_opp=" + $(".entrust_category ul li").eq(4).attr("type");
            loadArts(Ourl, startNum);
            $(".artfin_no_style").hide();
            $(".load-more").hide();
            $(".loading_style").show();

        });
    });

    $('.opa_background').tap(function(){
        var entrust_category_news = $(".entrust_category_news").css("display");
        if(entrust_category_news != "none"){
            $('.opa_background').hide();
            $(".entrust_category_news").hide();
        }
    });

    $(".bar_button li").off("tap").on("tap",function(){
        var buttonType = $(this).attr("buttonType");
        if(is_trade == 1){
            Ddivok1("不在交易时间");
        }else{
            $.ajax({
                type:"get",
                url:httpHost+"/Public/isLoginInfo",
                success:function(data){
                    if(data.status == 0){
                        Ddivok1(data.message);
                        setTimeout(function(){
                            location.href = data.url;
                        },1500);
                    }else{
                        var bargainTC = $(".bargainTC").css("display");
                        if(bargainTC == "none"){
                            $(".opa_background").show();
                            $(".bargainTC").show();
                            $.ajax({
                                type:"get",
                                url: httpHost+"/Bargain/getIssueList",
                                success: function(data){
                                    var Dhtml = '';
                                    Dhtml += '<div>';
                                    if(buttonType == 1){
                                        Dhtml += '<strong>买入</strong>';
                                        Dhtml += '<dl>';
                                        Dhtml += '<dt>发售编号：</dt>';
                                        Dhtml += '<dd><select class="buyselect">';
                                        for(var i=0; i<data.length; i++){
                                            Dhtml += '<option>'+ data[i].no +'</option>';
                                        }
                                        Dhtml += '</select></dd>';
                                        Dhtml += '</dl>';
                                        Dhtml += '<dl>';
                                        Dhtml += '<dt>可用金额：</dt>';
                                        Dhtml += '<dd><b>0</b> 元</dd>';
                                        Dhtml += '</dl>';
                                        Dhtml += '<dl>';
                                        Dhtml += '<dt>买入价格：</dt>';
                                        Dhtml += '<dd><input type="text" class="buy_money bs_monye" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;" /> 元</dd>';
                                        Dhtml += '</dl>';
                                        Dhtml += '<dl>';
                                        Dhtml += '<dt>买入数量：</dt>';
                                        Dhtml += '<dd><input type="text" class="buy_number bs_number" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;" /> 幅</dd>';
                                        Dhtml += '</dl>';
                                        Dhtml += '<dl style="margin-top: 10px;">';
                                        Dhtml += '<dd><p>所需金额 <i>0</i> 元，转让服务费 <i>0</i> 元</p></dd>';
                                        Dhtml += '</dl>';
                                    }else{
                                        Dhtml += '<strong>卖出</strong>';
                                        Dhtml += '<dl>';
                                        Dhtml += '<dt>发售编号：</dt>';
                                        Dhtml += '<dd><select class="sellselect">';
                                        for(var i=0; i<data.length; i++){
                                            Dhtml += '<option>'+ data[i].no +'</option>';
                                        }
                                        Dhtml += '</select></dd>';
                                        Dhtml += '</dl>';
                                        Dhtml += '<dl>';
                                        Dhtml += '<dt>可卖数量：</dt>';
                                        Dhtml += '<dd><b>0</b> 幅</dd>';
                                        Dhtml += '</dl>';
                                        Dhtml += '<dl>';
                                        Dhtml += '<dt>卖出价格：</dt>';
                                        Dhtml += '<dd><input type="text" class="sell_money bs_monye" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;" /> 元</dd>';
                                        Dhtml += '</dl>';
                                        Dhtml += '<dl>';
                                        Dhtml += '<dt>卖出数量：</dt>';
                                        Dhtml += '<dd><input type="text" class="sell_number bs_number" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;" /> 幅</dd>';
                                        Dhtml += '</dl>';
                                        Dhtml += '<dl style="margin-top: 10px;">';
                                        Dhtml += '<dd><p>所得金额 <i>0</i> 元，转让服务费 <i>0</i> 元</p></dd>';
                                        Dhtml += '</dl>';
                                    }
                                    Dhtml += '<dl>';
                                    Dhtml += '<dt>对方姓名：</dt>';
                                    Dhtml += '<dd><input type="text" class="opposite_name" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;" /></dd>';
                                    Dhtml += '</dl>';
                                    Dhtml += '<dl>';
                                    Dhtml += '<dt>对方手机：</dt>';
                                    Dhtml += '<dd><input type="text" class="opposite_phone" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;" /></dd>';
                                    Dhtml += '</dl>';
                                    Dhtml += '</div>';
                                    $(".bargainTC_news").html(Dhtml);
                                    if(buttonType == 1){
                                        $.ajax({
                                            type:"get",
                                            url: httpHost+"/Bargain/buyBargain?issue_id=" + $(".bargainTC_news select").val(),
                                            success: function(data){
                                                if(data.status == 0){
                                                    $(".bargainTC_news b").text("0");
                                                }else{
                                                    $(".bargainTC_news b").text(data.balance);
                                                }
                                                price_small = data.price_small;
                                                price_big = data.price_big;
                                            },
                                            error: function() {
                                                Ddivok1("服务器连接超时，请刷新！");
                                            }
                                        });
                                    }else{
                                        $.ajax({
                                            type:"get",
                                            url: httpHost+"/Bargain/sellBargain?issue_id=" + $(".sellselect").val(),
                                            success: function(data){
                                                if(data.status == 0){
                                                    $(".bargainTC_news b").text("0");
                                                }else{
                                                    $(".bargainTC_news b").text(data.new_active_quantity);
                                                }
                                                price_small = data.price_small;
                                                price_big = data.price_big;
                                            },
                                            error: function() {
                                                Ddivok1("服务器连接超时，请刷新！");
                                            }
                                        });
                                    }
                                    $(".bs_monye").keyup(function(){
                                        if($(this).val() != "" && $(".bs_number").val() != "" && RegExp(/^\d+(.\d{1,2})?$/g).test($(this).val()) == true && RegExp(/^[1-9]\d*$/g).test($(".bs_number").val()) == true){
                                            var num1 = parseFloat($(this).val() * $(".bs_number").val());//金额
                                            var num1_text = num1.toString();
                                            var num2 = parseFloat(($(this).val() * $(".bs_number").val())*0.002);//转让服务费
                                            var num2_text = num2.toString();
                                            if(num1_text.lastIndexOf('.')>-1){
                                                $(".bargainTC_news p i:first-child").text(num1_text.substring(0,num1_text.lastIndexOf('.')+3));
                                            }else{
                                                $(".bargainTC_news p i:first-child").text(num1_text);
                                            }
                                            if(num2_text.lastIndexOf('.')>-1){
                                                $(".bargainTC_news p i:last-child").text(num2_text.substring(0,num2_text.lastIndexOf('.')+3));
                                            }else{
                                                $(".bargainTC_news p i:last-child").text(num2_text);
                                            }
                                        }else{
                                            $(".bargainTC_news p i:first-child").text("0");
                                            $(".bargainTC_news p i:last-child").text("0");
                                        }
                                    });
                                    $(".bs_number").keyup(function(){
                                        if($(this).val() != "" && $(".bs_monye").val() != "" && RegExp(/^[1-9]\d*$/g).test($(this).val()) == true && RegExp(/^\d+(.\d{1,2})?$/g).test($(".bs_monye").val()) == true){
                                            var num1 = parseFloat($(this).val() * $(".bs_monye").val());//金额
                                            var num1_text = num1.toString();
                                            var num2 = parseFloat(($(this).val() * $(".bs_monye").val())*0.002);//转让服务费
                                            var num2_text = num2.toString();
                                            if(num1_text.lastIndexOf('.')>-1){
                                                $(".bargainTC_news p i:first-child").text(num1_text.substring(0,num1_text.lastIndexOf('.')+3));
                                            }else{
                                                $(".bargainTC_news p i:first-child").text(num1_text);
                                            }
                                            if(num2_text.lastIndexOf('.')>-1){
                                                $(".bargainTC_news p i:last-child").text(num2_text.substring(0,num2_text.lastIndexOf('.')+3));
                                            }else{
                                                $(".bargainTC_news p i:last-child").text(num2_text);
                                            }
                                        }else{
                                            $(".bargainTC_news p i:first-child").text("0");
                                            $(".bargainTC_news p i:last-child").text("0");
                                        }
                                    });
                                    $(".buyselect").change(function(){
                                        $.ajax({
                                            type:"get",
                                            url: httpHost+"/Bargain/buyBargain?issue_id=" + $(this).val(),
                                            success: function(data){
                                                if(data.status == 0){
                                                    $(".bargainTC_news b").text("0");
                                                }else{
                                                    $(".bargainTC_news b").text(data.balance);
                                                }
                                                price_small = data.price_small;
                                                price_big = data.price_big;
                                            },
                                            error: function() {
                                                Ddivok1("服务器连接超时，请刷新！");
                                            }
                                        });
                                    });
                                    $(".sellselect").change(function(){
                                        $.ajax({
                                            type:"get",
                                            url: httpHost+"/Bargain/sellBargain?issue_id=" + $(this).val(),
                                            success: function(data){
                                                if(data.status == 0){
                                                    $(".bargainTC_news b").text("0");
                                                }else{
                                                    $(".bargainTC_news b").text(data.new_active_quantity);
                                                }
                                                price_small = data.price_small;
                                                price_big = data.price_big;
                                            },
                                            error: function() {
                                                Ddivok1("服务器连接超时，请刷新！");
                                            }
                                        });
                                    });
                                },
                                error: function() {
                                    Ddivok1("服务器连接超时，请刷新！");
                                }
                            });
                        }
                        $("#bargainTC_true").off("tap").on("tap",function(){
                            var Dnumberbs = 0;
                            var Dtext = $(this).parent().prev(".bargainTC_news").find("strong").text();//判断是买入还是卖出
                            var selectOption = $(".bargainTC_news select").val();//获取是哪期画
                            var sebu_cc = $(".bargainTC_news dl dd b").text();//获取余额和持仓
                            var opposite_name = $(".opposite_name").val();//获取对方姓名
                            var opposite_phone = $(".opposite_phone").val();//获取对方手机号
                            if(Dtext == "买入"){
                                var buy_money = $(".buy_money").val();//获取买入价格
                                var buy_number = $(".buy_number").val();//获取买入数量
                                if(sebu_cc == 0){
                                    Ddivok1("可用余额不足");
                                }else if(buy_money == "" || RegExp(/^\d+(.\d{1,2})?$/g).test(buy_money) == false){
                                    Ddivok1("请正确输入买入价格");
                                }else if(parseFloat(buy_money) < parseFloat(price_small) || parseFloat(buy_money) > parseFloat(price_big)){
                                    Ddivok1("价格请在" + price_small + "-" + price_big + "之间");
                                }else if(buy_number == "" || RegExp(/^[1-9]\d*$/g).test(buy_number) == false){
                                    Ddivok1("请正确输入买入数量");
                                }else if(opposite_name == ""){
                                    Ddivok1("请正确输入对方姓名");
                                }else if(opposite_phone == "" || RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/).test(opposite_phone) == false){
                                    Ddivok1("请正确输入对方手机号");
                                }else if((parseFloat($(".bargainTC_news p i:first-child").text()) + parseFloat($(".bargainTC_news p i:last-child").text())) > parseFloat($(".bargainTC_news dd b").text())){
                                    Ddivok1("可用余额不足");
                                }else{
                                    $(".Ddivok2").show();
                                    $(".Ddivok2-content-info p").text("所需金额" + $(".bargainTC_news p i:first-child").text() + "元，转让服务费" + $(".bargainTC_news p i:last-child").text() + "元，是否确认申请？");
                                    $(".Ddivok2-content-button p").eq(0).off("tap").on("tap",function(){
                                        $('.Ddivok2').hide();
                                        $('.opa_background').show();
                                    });
                                    $("#Ddivok-true").off("tap").on("tap",function(){
                                        if(Dnumberbs == 0){
                                            Dnumberbs = 1;
                                            $.ajax({
                                                type:"get",
                                                url: httpHost+"/Bargain/saveBargain?issue_id=" + selectOption + "&count=" + buy_number + "&price=" + buy_money + "&type=" + 1 + "&opp_phone=" + opposite_phone + "&opp_name=" + opposite_name,
                                                success: function(data){
                                                    if(data.status == 0){
                                                        Ddivok1(data.info);
                                                    }else{
                                                        Ddivok1(data.info);
                                                        setTimeout(function(){
                                                            history.go(0);
                                                        },1500);
                                                    }
                                                },
                                                error: function() {
                                                    Ddivok1("服务器连接超时，请刷新！");
                                                }
                                            });
                                        }
                                    });
                                }
                            }else{
                                var sell_money = $(".sell_money").val();//获取卖出价格
                                var sell_number = $(".sell_number").val();//获取卖出数量
                                if(sebu_cc == 0){
                                    Ddivok1("可卖数量不足");
                                }else if(sell_money == "" || RegExp(/^\d+(.\d{1,2})?$/g).test(sell_money) == false){
                                    Ddivok1("请正确输入卖出价格");
                                }else if(parseFloat(sell_money) < parseFloat(price_small) || parseFloat(sell_money) > parseFloat(price_big)){
                                    Ddivok1("价格请在" + price_small + "-" + price_big + "之间");
                                }else if(sell_number == "" || RegExp(/^[1-9]\d*$/g).test(sell_number) == false){
                                    Ddivok1("请正确输入卖出数量");
                                }else if(opposite_name == ""){
                                    Ddivok1("请正确输入对方姓名");
                                }else if(opposite_phone == "" || RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/).test(opposite_phone) == false){
                                    Ddivok1("请正确输入对方手机号");
                                }else if(sell_number > parseInt($(".bargainTC_news b").text())){
                                    Ddivok1("可交易数量不足");
                                }else{
                                    $(".Ddivok2").show();
                                    $(".Ddivok2-content-info p").text("所得金额" + $(".bargainTC_news p i:first-child").text() + "元，转让服务费" + $(".bargainTC_news p i:last-child").text() + "元，是否确认申请？");
                                    $(".Ddivok2-content-button p").eq(0).off("tap").on("tap",function(){
                                        $('.Ddivok2').hide();
                                        $('.opa_background').show();
                                    });
                                    $("#Ddivok-true").off("tap").on("tap",function(){
                                        if(Dnumberbs == 0){
                                            Dnumberbs = 1;
                                            $.ajax({
                                                type:"get",
                                                url: httpHost+"/Bargain/saveBargain?issue_id=" + selectOption + "&count=" + sell_number + "&price=" + sell_money + "&type=" + 2 + "&opp_phone=" + opposite_phone + "&opp_name=" + opposite_name,
                                                success: function(data){
                                                    if(data.status == 0){
                                                        Ddivok1(data.info);
                                                    }else{
                                                        Ddivok1(data.info);
                                                        setTimeout(function(){
                                                            history.go(0);
                                                        },1500);
                                                    }
                                                },
                                                error: function() {
                                                    Ddivok1("服务器连接超时，请刷新！");
                                                }
                                            });
                                        }
                                    });
                                }
                            }
                        });
                    }
                }
            });
        }
    });

});

function appendLi(data) {

    is_trade = data.is_trade;

    if(is_trade == 0){
        $(".bar_button ul li").css("background","#f14958");
    }else{
        $(".bar_button ul li").css("background","#888");
    }

    if(data.more == 0 || data.more == null){
        $(".load-more").hide();
    }else{
        $(".load-more").show();
        imgLoaded = true;
    }

    if(data.count == 0){
        $(".bar_big_bg").css("background","#fff");
        $(".artfin_no_style").show();
    }else{
        $(".bar_big_bg").css("background","url('../img/login_bg.gif')");
        $(".artfin_no_style").hide();
        var Dhtml = '';
        for (var i = 0; i < data.list.length; i++) {
            var jsondata = data.list[i];
            Dhtml += '<div class="bar_index_news" id="'+ jsondata.id +'">';
            Dhtml += '<strong>'+ jsondata.issue_name +'</strong>';
            Dhtml += '<p>发起方<span>'+ jsondata.send_person_name +' - '+ jsondata.send_phone +'</span></p>';

            if(jsondata.type == 1){
                Dhtml += '<p>买入价格<span>'+ jsondata.price +' 元</span></p>';
                Dhtml += '<p>买入数量<span>'+ jsondata.quantity +' 幅</span></p>';
            }else{
                Dhtml += '<p>卖出价格<span>'+ jsondata.price +' 元</span></p>';
                Dhtml += '<p>卖出数量<span>'+ jsondata.quantity +' 幅</span></p>';
            }

            Dhtml += '<p>金额<span>'+ jsondata.amount +' 元</span></p>';
            Dhtml += '<p>转让服务费<span>'+ jsondata.trade_fee +' 元</span></p>';
            Dhtml += '<p>应答方<span>'+ jsondata.receive_person_name +' - '+ jsondata.receive_phone +'</span></p>';
            Dhtml += '<p>发起时间<span>'+ jsondata.created +'</span></p>';

            if(jsondata.stage_id == 3){
                Dhtml += '<p>应答时间<span>'+ jsondata.modified +'</span></p>';
            }else if(jsondata.stage_id == 6){
                Dhtml += '<p>应答时间<span>'+ jsondata.modified +'</span></p>';
                Dhtml += '<p>拒绝理由<span>'+ jsondata.remark +'</span></p>';
            }else{

            }

            Dhtml += '<div class="clear"></div>';

            if(jsondata.is_opposite == 1 && jsondata.stage_id == 1){
                Dhtml += '<div class="bar_news_button">';
                Dhtml += '<span class="yes_data">同意</span>';
                Dhtml += '<span class="no_data" style="margin-right: 60px;">拒绝</span>';
                Dhtml += '</div>';
            }else if(jsondata.is_opposite == 2 && jsondata.stage_id == 1){
                Dhtml += '<div class="bar_news_button">';
                Dhtml += '<i>'+ jsondata.stage_name +'</i>';
                Dhtml += '<span class="revoke_data">撤销</span>';
                Dhtml += '</div>';
            }else{
                Dhtml += '<div class="bar_news_button">';
                Dhtml += '<i>'+ jsondata.stage_name +'</i>';
                Dhtml += '</div>';
            }

            Dhtml += '<div class="clear"></div>';
            Dhtml += '</div>';
        }
        $(".bar_news").append(Dhtml);
        var Dtap_ctj = 0;
        //撤销
        $(".revoke_data").off("tap").on("tap",function(){
            var dataid = $(this).parent().parent().attr("id");
            $(".Ddivok2").show();
            $(".Ddivok2-content-info p").text("是否确认撤销？");
            $("#Ddivok-true").off("tap").on("tap",function(){
                if(Dtap_ctj == 0){
                    Dtap_ctj = 1;
                    $.ajax({
                        type:"get",
                        url: httpHost+"/Bargain/delBargain?bargain_id=" + dataid,
                        success: function(data){
                            if(data.status == 0){
                                Ddivok1(data.info);
                                Dtap_ctj = 0;
                            }else{
                                Ddivok1("撤销成功");
                                setTimeout(function(){
                                    history.go(0);
                                },1500);
                            }
                        },
                        error: function() {
                            Ddivok1("服务器连接超时，请刷新！");
                        }
                    });
                }
            });
        });
        //同意
        $(".yes_data").off("tap").on("tap",function(){
            var dataid = $(this).parent().parent().attr("id");
            $(".Ddivok2").show();
            $(".Ddivok2-content-info p").text("是否同意议价？");
            $("#Ddivok-true").off("tap").on("tap",function(){
                if(Dtap_ctj == 0){
                    Dtap_ctj = 1;
                    $.ajax({
                        type:"get",
                        url: httpHost+"/Bargain/bidBargain?bargain_id=" + dataid,
                        success: function(data){
                            if(data.status == 0){
                                Ddivok1(data.info);
                                Dtap_ctj = 0;
                            }else{
                                Ddivok1("议价成功");
                                setTimeout(function(){
                                    history.go(0);
                                },1500);
                            }
                        },
                        error: function() {
                            Ddivok1("服务器连接超时，请刷新！");
                        }
                    });
                }
            });
        });
        //拒绝
        $(".no_data").off("tap").on("tap",function(){
            var dataid = $(this).parent().parent().attr("id");
            $(".Ddivok2").show();
            $(".Ddivok2-content-info p").html("<input type='text' placeholder='请输入拒绝理由' class='reasonInput' style='padding: 10px; border-radius: 3px; border: 1px solid #808080;' />");
            $("#Ddivok-true").off("tap").on("tap",function(){
                if(Dtap_ctj == 0){
                    Dtap_ctj = 1;
                    $.ajax({
                        type:"get",
                        url: httpHost+"/Bargain/delBargain?bargain_id=" + dataid + "&type_id=" + 1 + "&remark=" + $(".reasonInput").val(),
                        success: function(data){
                            if(data.status == 0){
                                Ddivok1(data.info);
                                Dtap_ctj = 0;
                            }else{
                                Ddivok1("拒绝成功");
                                setTimeout(function(){
                                    history.go(0);
                                },1500);
                            }
                        },
                        error: function() {
                            Ddivok1("服务器连接超时，请刷新！");
                        }
                    });
                }
            });
        });
    }

}